package com.huike.web.controller.clues;

import com.huike.clues.domain.dto.CreateClueTrackRecordDTO;
import com.huike.clues.domain.vo.ClueTrackListVO;
import com.huike.clues.domain.vo.PageClueVO;
import com.huike.clues.service.TbClueTrackRecordService;
import com.huike.common.core.domain.AjaxResult;
import com.huike.common.core.page.TableDataInfo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 线索跟进记录Controller
 *
 * @date 2023-04-22
 */
@RequestMapping("/clues/record")
@RequiredArgsConstructor
@RestController
@Slf4j
public class TbClueTrackRecordController {

    private final TbClueTrackRecordService service;

    /**
     * 新增线索跟进记录
     */
    @PostMapping
    public AjaxResult<?> create(@RequestBody CreateClueTrackRecordDTO dto) {
        log.info("Get CreateClueTrackRecordDTO: {}", dto);
        service.create(dto);
        return AjaxResult.success();
    }

    /**
     * 查询线索跟进记录列表
     *
     * @param clueId 线索id
     * @return 返回跟进记录集合
     */
    @GetMapping("/list")
    public TableDataInfo<List<ClueTrackListVO>> list(Long clueId) {
        log.info("Get clueId: {}", clueId);
        return service.getClueTracklist(clueId);
    }

    /**
     * 获取线索跟进记录详细信息
     *
     * @param id 线索id
     * @return 返回详情信息
     */
    @GetMapping("/{id}")
    public AjaxResult<PageClueVO> getInfoById(@PathVariable Long id) {
        log.info("Get id: {}", id);
        return AjaxResult.success(service.getInfoById(id));
    }

}
